package com.liyunlong.demoliyunlong.shangji2.pojo;

import com.liyunlong.demoliyunlong.shangji2.Service.Monitor;
import com.liyunlong.demoliyunlong.shangji2.Service.Motherboard;

public class Computer {
//    主板
    private final Motherboard motherboard;
//    显示器
    private final Monitor monitor;

    private Computer(Builder builder) {
        this.motherboard = builder.motherboard;
        this.monitor = builder.monitor;
    }
// 电脑的启动方法
    public void start() {
        motherboard.boot();
        monitor.displayOutput();
    }

//    构造器 主板 显示器
    public static class Builder {
        private Motherboard motherboard;
        private Monitor monitor;

        public Builder setMotherboard(Motherboard motherboard) {
            this.motherboard = motherboard;
            return this;
        }

        public Builder setMonitor(Monitor monitor) {
            this.monitor = monitor;
            return this;
        }
        public Computer build() {
            return new Computer(this);
        }
    }
}